package com.atguigu.guli.service.edu.controller.admin;

import com.atguigu.guli.service.edu.entity.Subject;
import com.atguigu.guli.service.edu.service.SubjectService;
import com.atguigu.guli.service.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Api(tags = "学科模块")
@RestController
@RequestMapping("/edu/subject")

public class AdminSubjectController {
    @Autowired
    SubjectService subjectService;

    @ApiOperation("上传文件")
    @PostMapping("/import")
    public R importFile(MultipartFile file) {
        System.out.println(file.getOriginalFilename() + " , " + file.getSize());
        subjectService.importFile(file);
        return R.ok();
    }

    @ApiOperation("查询数据给前端展示")
    @GetMapping("/getSubjectList")
    public R getSubjectList(){
        List<Subject> subjectList = subjectService.getSubjectList();

        return R.ok().data("items",subjectList);
    }
}

